# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Mika Havela <mika.havela@gmail.com>
# Maintainer: Mika Havela <mika.havela@gmail.com>
pkgname=zziplib
pkgver=0.13.71
pkgrel=0
pkgdesc="Lightweight library to easily extract data from zip files"
options="!check" # Some tests fail
url="https://github.com/gdraheim/zziplib"
arch="all"
license="LGPL-2.0-or-later MPL-1.1"
makedepends="cmake zlib-dev python3 bash"
checkdepends="zip"
subpackages="$pkgname-dev $pkgname-doc $pkgname-utils"
source="zziplib-$pkgver.tar.gz::https://github.com/gdraheim/zziplib/archive/v$pkgver.tar.gz"

# secfixes:
#   0.13.69-r2:
#     - CVE-2018-16548
#     - CVE-2018-17828

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_STATIC_LIBS=False \
		-DBUILD_TESTS=OFF \
		-DMSVC_STATIC_RUNTIME=OFF \
		-DZZIPSDL=OFF \
		-DZZIPTEST=OFF \
		-DZZIPWRAP=OFF \
		$CMAKE_CROSSOPTS .
	make -C build
}

check() {
	make -C build check
}

package() {
	make -C build DESTDIR="$pkgdir" install
}

utils() {
	pkgdesc="Utilities for the zziplib library"
	install -d "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

sha512sums="e035d0ac26dca78335ae3defc652543ff7b353a1a95d76ed1beeb21a08e16f287a62d488f528cfbb77d5b558581b68d439aa0823577524e9aa61a3cf5f208cb5  zziplib-0.13.71.tar.gz"
